package com.boliq.lol.ui.news;

import android.os.Bundle;
import android.view.View;
import android.widget.TableLayout;
import android.widget.TextView;

import androidx.viewpager.widget.ViewPager;

import com.boliq.lol.R;
import com.boliq.lol.adapter.NewsVpAdapter;
import com.boliq.lol.base.BaseFragment;
import com.boliq.lol.bean.NewsTypeBean;
import com.google.android.material.tabs.TabLayout;

public class NewsMainFragment extends BaseFragment {

    public static Bundle newArgument(String title) {
        Bundle args = new Bundle();
        args.putString("title", title);
        return args;
    }

    private TabLayout mTabLayout;
    private ViewPager mViewPager;
    private NewsVpAdapter mVpAdapter;//viewpager 对应的adapter

    @Override
    protected void initArgumentData(Bundle arguments) {
        super.initArgumentData(arguments);
    }

    @Override
    protected int rootLayout() {
        return R.layout.fragment_home_news;
    }

    @Override
    protected void initView(View view) {
        mTabLayout = view.findViewById(R.id.tab_news_top);
        mViewPager = view.findViewById(R.id.vp_content);
    }

    @Override
    protected void initData() {
        mVpAdapter = new NewsVpAdapter(getChildFragmentManager());
        mViewPager.setAdapter(mVpAdapter);
        mTabLayout.setupWithViewPager(mViewPager);
        mTabLayout.setInlineLabel(true);
    }

    @Override
    protected void bindData() {
        super.bindData();
        mVpAdapter.addData(new NewsTypeBean(NewsTypeBean.TYPE_ARTICLE,"关注"));
        mVpAdapter.addData(new NewsTypeBean(NewsTypeBean.TYPE_ARTICLE,"推荐"));
        mVpAdapter.addData(new NewsTypeBean(NewsTypeBean.TYPE_ARTICLE,"手游"));
        mVpAdapter.addData(new NewsTypeBean(NewsTypeBean.TYPE_ARTICLE,"云顶"));
        mVpAdapter.addData(new NewsTypeBean(NewsTypeBean.TYPE_ARTICLE,"赛事"));
        mVpAdapter.addData(new NewsTypeBean(NewsTypeBean.TYPE_ARTICLE,"视屏"));
        mVpAdapter.addData(new NewsTypeBean(NewsTypeBean.TYPE_ARTICLE,"电视台"));
        mVpAdapter.addData(new NewsTypeBean(NewsTypeBean.TYPE_ARTICLE,"活动"));
    }

    @Override
    protected void bindEvent() {

    }
}
